package com.nondo.dean.product.model.result;

import java.util.ArrayList;
import java.util.List;

import com.nondo.dean.common.tool.BeanUtils;
import com.nondo.dean.product.model.AdminCategoryBean;
import com.nondo.dean.product.model.CategoryBean;

public class AdminCategoryResult {

    private Integer value; // 父分类ID
    private String label; // 父分类名称
    private String image; // 父分类图片
    private Integer orderNum; // 父分类排序值
    private List<AdminCategoryBean> children; // 子分类列表

    /**
     * @return the value
     */
    public Integer getValue() {
        return value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(Integer value) {
        this.value = value;
    }

    /**
     * @return the label
     */
    public String getLabel() {
        return label;
    }

    /**
     * @param label the label to set
     */
    public void setLabel(String label) {
        this.label = label;
    }

    /**
     * @return the image
     */
    public String getImage() {
        return image;
    }

    /**
     * @param image the image to set
     */
    public void setImage(String image) {
        this.image = image;
    }

    /**
     * @return the orderNum
     */
    public Integer getOrderNum() {
        return orderNum;
    }

    /**
     * @param orderNum the orderNum to set
     */
    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    /**
     * @return the children
     */
    public List<AdminCategoryBean> getChildren() {
        return children;
    }

    /**
     * @param children the children to set
     */
    public void setChildren(List<AdminCategoryBean> children) {
        this.children = children;
    }
    
    public static AdminCategoryResult covertToBean(CategoryResult categoryResult) {
        AdminCategoryResult adminCategoryResult = new AdminCategoryResult();
        BeanUtils.copy(categoryResult, adminCategoryResult);
        adminCategoryResult.setValue(categoryResult.getId());
        adminCategoryResult.setLabel(categoryResult.getName());
        List<CategoryBean> categoryBeanList = categoryResult.getChildrenList();
        List<AdminCategoryBean> adminCategoryBeanList = new ArrayList<AdminCategoryBean>();
        for (CategoryBean categoryBean : categoryBeanList) {
            AdminCategoryBean adminCategoryBean = AdminCategoryBean.covertToBean(categoryBean);
            adminCategoryBeanList.add(adminCategoryBean);
        }
        adminCategoryResult.setChildren(adminCategoryBeanList);
        return adminCategoryResult;
    }

}
